home *** CD-ROM | disk | FTP | other *** search
/ stazsoftware.com / www.stazsoftware.com.tar / www.stazsoftware.com / futurebasic / sample-code / FileWritable.sit / FN FBFileWritable next >
Text File  |  2003-08-25  |  2KB  |  72 lines

  1.  
  2. /*
  3.      while this has been presented as an entire program, the real meat is a single, tiny
  4.      function called...
  5.  
  6.                FN FBFileWritable( fs as ^FSSpec)
  7.  
  8.      it returns zero or one to say that you can write to the file [1] or not [0]. it's pretty
  9.      well idiot proof [until they invent a new idiot.
  10.  
  11. */
  12.  
  13. '------------------------ Begin Test Program -----------------------
  14. '
  15. '      0 = No way, no how, can I write to this file
  16. '      1 = Exists and writable
  17. '
  18. '~'1
  19. clear local mode
  20. dim err
  21. dim @ ref%
  22. dim f as FSSpec
  23. local fn FBFileWritable( fs as ^FSSpec)
  24. f = fs
  25. err = FN FSpOpenDF(f,_fswrperm,ref)
  26. if err == 0 then err = fn fsclose(ref)
  27. end fn = (err == 0)' 1 = OK & Can Write!
  28. '~'1
  29. clear local fn doMenu
  30. dim as long menuid, itemid, id, k
  31. dim Afile$
  32. dim Afilespec as FSSpec
  33. menuid = menu(_menuID)
  34. itemid = menu(_itemID)
  35. select case menuid
  36. case 1
  37. select case itemid'File Menu
  38. case 1'Menu "OPEN"
  39. Afile$ = files$(_FSSpecOpen,,"file to test",Afilespec)
  40. k = fn FBFileWritable( Afilespec )
  41. long if k
  42. print "I Can write to """;Afile$;""" Cool..."
  43. xelse
  44. print "Can't write to """;Afile$;""" Drat..."
  45. end if
  46. case 3 : end'menu "QUIT"
  47. end select
  48. end select
  49. menu
  50. end fn
  51. '~'1
  52. clear local fn InitializeGUI
  53. gFBUseNavServices = _zTrue
  54. menu 1, 0 , _enable  , "File"
  55. menu 1, 1 ,  _enable , "Open╔/O;(-;Quit/Q"
  56. window 1,"TEST",(10,50)-(300,300)
  57. text _monaco,9
  58. end fn
  59. '~'1
  60. fn InitializeGUI
  61. on menu fn doMenu
  62. '~'1
  63. do
  64. handleevents
  65. until 0
  66. '~'1
  67. end
  68. '-------------------------- End Test Program --------------------------
  69.  
  70.  
  71.  
  72.